package com.loe.test.recy

import android.os.Bundle
import com.loe.mvp.BaseActivity
import com.loe.mvp.ext_app.createStringAdapter
import com.loe.mvp.ext_java.delay
import com.loe.test.R
import kotlinx.android.synthetic.main.activity_recycler.*
import kotlinx.android.synthetic.main.list_item.view.*

class RecyclerActivity : BaseActivity()
{
//    private val binding by lazy { ActivityRecyclerBinding.inflate(layoutInflater) }

    override fun onCreate(savedInstanceState: Bundle?)
    {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_recycler)

        val adapter = createStringAdapter(R.layout.list_item)
        { holder, s ->
            textName.text = s
        }

//        refreshLayout.adapter = adapter
//        refreshLayout.setOnLoaData()
//        {
//            delay(500)
//            {
//                val aList = ArrayList<String>()
//                when (refreshLayout.page)
//                {
//                    1 -> for (i in 1..15) aList.add(i.toString() + Math.random().toString())
//                    2 -> for (i in 6..18) aList.add(i.toString() + Math.random().toString())
//                    3 ->
//                    {
//                        refreshLayout.loadError(it)
//                        refreshLayout.page++
//                        return@delay
//                    }
//                    4 -> for (i in 9..15) aList.add(i.toString() + Math.random().toString())
//                }
//                refreshLayout.loadOk(it, aList)
//            }
//        }
//        refreshLayout.loadData()
    }
}